/**
 * 职位类型缓存工具类
 * 用于缓存职位类型数据，减少网络请求
 */
import type { JobTypeItem } from '../api/resource'

class JobTypeCache {
  // 一级职位类型缓存
  private topList: JobTypeItem[] | null = null
  
  // 子级职位类型缓存，key 为父级 ID
  private childrenMap: Map<string, JobTypeItem[]> = new Map()
  
  /**
   * 获取一级职位类型列表
   */
  getTopList(): JobTypeItem[] | null {
    return this.topList
  }
  
  /**
   * 设置一级职位类型列表
   */
  setTopList(list: JobTypeItem[]): void {
    this.topList = list
  }
  
  /**
   * 获取子级职位类型列表
   */
  getChildren(fatherId: string): JobTypeItem[] | null {
    return this.childrenMap.get(fatherId) || null
  }
  
  /**
   * 设置子级职位类型列表
   */
  setChildren(fatherId: string, list: JobTypeItem[]): void {
    this.childrenMap.set(fatherId, list)
  }
  
  /**
   * 清除所有缓存
   */
  clear(): void {
    this.topList = null
    this.childrenMap.clear()
  }
}

// 导出单例
export const jobTypeCache = new JobTypeCache()





















